<template>
<div class="bh-alert" :class="[typeClass]" v-show="visible">
	<div class="bh-alert__content">
		<span class="bh-alert__title">
			<slot name="title">{{ title }}</slot>
		</span>
		<i class="bh-alert__closebtn bh-icon-close" v-show="closable" @click="close()"></i>
	</div>
</div>
</template>

<script>
export default {
	name: 'bh-alert',
	props: {
		type: {
			type: String,
			default: 'info',
		},
		title: {
			type: String,
			default: '',
		},
		closable: {
			type: Boolean,
			default: true,
		},
	},
	data() {
		return {
			visible: true,
		}
	},
	methods: {
		close() {
			this.visible = false;
			this.$emit('close');
		},
	},
	computed: {
		typeClass() {
			return `bh-alert-${ this.type }`;
		},
	},
}
</script>
